package com.elontian.http.async2.strategy.impl;

import java.util.Map;

import com.elontian.client.HttpRequestClient;
import com.elontian.http.async2.modle.Response;
import com.elontian.http.async2.strategy.IAsyncStrategy;
import com.elontian.http.async2.util.HttpParams;
import com.elontian.util.CheckUtil;

public class AsyncPostStrategy implements IAsyncStrategy {

	private String url;
	private Map<String, Object> params;
	private Response response = new Response();

	public AsyncPostStrategy(String url, Map<String, Object> params) {
		super();
		this.url = url;
		this.params = params;
	}

	@Override
	public Response getResponse() throws Exception {
		// TODO Auto-generated method stub
		String result = HttpRequestClient.SyncPost(url, params);

		if (CheckUtil.isNotNullString(result)) {
			response.add(HttpParams.URL, url);
			response.add(HttpParams.RESULT, result);
			response.setHavaResult(true);
		} else {
			response.setHavaResult(false);
		}

		return response;
	}

}
